package com.sq.system.utils;

import com.sq.system.pojo.SysRole;

import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * @Author Li sir
 * @Date 2024/9/29
 */
public class RoleUtil {


    public static Set<String> getUserRoleIds(List<SysRole> roleList){

        HashSet<String> set = new HashSet<>();

        if (Objects.isNull(roleList) || roleList.isEmpty()){
            return set;
        }

        Set<String> collect = roleList.stream().map(SysRole::getRoleId).collect(Collectors.toSet());
        return collect;
    }

    public static Set<String> getUserRoleStrs(List<SysRole> roleList){

        HashSet<String> set = new HashSet<>();

        if (Objects.isNull(roleList) || roleList.isEmpty()){
            return set;
        }

        Set<String> collect = roleList.stream().map(SysRole::getRoleName).collect(Collectors.toSet());
        return collect;
    }

}
